<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/7/27 0027
  Time: 14:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <base href="<%=basePath%>">
    <meta charset="utf-8"/>
    <title></title>
    <link rel="stylesheet" type="text/css" href="easyui-1.4/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="easyui-1.4/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="easyui-1.4/demo/demo.css">
    <script type="text/javascript" src="easyui-1.4/jquery.min.js"></script>
    <script type="text/javascript" src="easyui-1.4/jquery.easyui.min.js"></script>

</head>
<body>
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title" id="index-page-title" style="font: normal 30px/0.8em '微软雅黑'">孜点教科</h3>
        <ul class="page-breadcrumb breadcrumb">
            <%--<li>
                <i class="fa fa-home"></i>
                首页
                <i class="fa fa-angle-right"></i>
            </li>--%>
            <li>
                <%--<a href="javascript:;">--%>
                活动管理
                <%--</a>--%>
                <i class="fa fa-angle-right"></i>
            </li>
            <li>
                <%--<a href="javascript:;">--%>
                添加活动
                <%--</a>--%>
            </li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB-->
    </div>
</div>
<div style="margin:20px 0;"></div>
<div style="width:500px; margin:auto">
    <div class="easyui-panel" title="请按规定填写数据添加一个活动" style="width:500px;margin:0px auto;">
    <div style="padding:10px 60px 20px 60px">
        <form id="ff" class="easyui-form" method="post" data-options="novalidate:true"  enctype="multipart/form-data">
            <table style="margin-top:20px; ">
                <tr>
                    <td style="display:inline-block;height:30px;line-height:30px;width:80px;">活动标题:</td>
                    <td><input class="easyui-validatebox textbox" name="activityTitle"
                               data-options="required:true,missingMessage:'不能为空！',validType:'length[1,20]',invalidMessage:'长度请为1到20之间！'" style="width:300px;height:30px; border:1px solid #d6dde5;background-color:transparent;padding:0px 10px;margin-bottom: 10px;"></td>
                </tr>
                <tr>
                    <td style="display:inline-block;height:30px;line-height:30px;width:80px;">活动时间:</td>
                    <td><input class="easyui-datetimebox" name="activityTime" data-options="required:true,missingMessage:'不能为空！'" style="width:180px;height:30px; border:1px solid #d6dde5;background-color:transparent;padding:0px 10px;margin-bottom:10px;"></td>
                </tr>
                <%--<tr>--%>
                    <%--<td>活动类型:</td>--%>
                    <%--<td><select  class="easyui-combobox" name="activityType"  style="width:100%">--%>
                        <%--<option value="课外活动">课外活动</option>--%>
                        <%--<option value="校园活动">校园活动</option>--%>
                    <%--</select> </td>--%>
                <%--</tr>--%>
                <tr>
                    <td style="display:inline-block;height:30px;line-height:30px;width:80px;margin:10px 0px;">活动上限人数:</td>
                    <td ><select class="easyui-combobox" name="functionAttendanceSum"  style="width:300px;height:30px; border:1px solid #d6dde5;background-color:transparent;padding:0px 10px;margim:10px 0px;">
                        <option value="10">10</option>
                        <option value="20">20</option>
                    </select></td>
                </tr>
                <tr >
                    <td style="display:inline-block;height:30px;line-height:30px;width:70px;">活动发布方:</td>
                    <td><input class="easyui-validatebox textbox" name="activityCollege"
                               data-options="required:true,missingMessage:'不能为空！',validType:'length[1,20]',invalidMessage:'长度请为1到20之间！'" style="width:300px;height:30px; border:1px solid #d6dde5;background-color:transparent;padding:0px 10px;margin-bottom: 10px;"></td>
                </tr>
                <tr>
                    <td style="display:inline-block;height:30px;line-height:30px;width:60px;">联系方式:</td>
                    <td><input class="easyui-validatebox textbox" name="activityCollegeNumber"
                               data-options="required:true,missingMessage:'不能为空！',validType:'length[1,20]',invalidMessage:'长度请为1到20之间！'" placeholder="请输入活动发布方联系方式" style="width:300px;height:30px; border:1px solid #d6dde5;background-color:transparent;padding:0px 10px;margin-bottom: 10px;"></td>
                </tr>
                <tr>
                    <td style="display:inline-block;height:30px;line-height:30px;width:60px;">活动地点:</td>
                    <td><input class="easyui-validatebox textbox" name="activityLocation"
                               data-options="required:true,missingMessage:'不能为空！',validType:'length[1,20]',invalidMessage:'长度请为1到20之间！'" style="width:300px;height:30px; border:1px solid #d6dde5;background-color:transparent;padding:0px 10px;"></td>
                </tr>
                <tr>
                    <td style="display:inline-block;height:30px;line-height:30px;width:60px;margin:10px 0px">活动图片:</td>
                    <%--<td><input class="easyui-filebox" name="file1" style="width:300px;height:30px; border:1px solid #d6dde5;background-color:transparent;padding:0px 10px;margin-bottom:10px;"></td>--%>
                    <td><input type='file' name='file1' style="width:100%"></td>
                </tr>
                <tr>
                    <td style="display:inline-block;height:30px;line-height:30px;width:60px;">活动内容:</td>
                    <td><textarea class="easyui-validatebox textbox" name="activityContent"
                                  data-options="required:true,missingMessage:'不能为空！',validType:'length[1,450]',invalidMessage:'长度请为1到20之间！'"
                                  style="width:300px;height:80px; border:1px solid #d6dde5;background-color:transparent;padding:0px 10px;marginm:10px 0px;word-break:break-all;white-space: normal;"></textarea></td>
                </tr>
                <tr>
                    <td style="display:inline-block;height:50px;line-height:15px;width:80px;padding-bottom:10px;;margin: 10px 0px;">点击添加活动内容图片（最多四张）:</td>
                    <td><a href="javascript:void(0)" id="add" class="easyui-linkbutton" style="width:80px;height:30px;">添加</a></td>
                </tr>
            </table>
            <div id="ff1" style="text-align:center;padding:5px"></div>
            <input type="hidden" value="${user.teacherid}" name="manageId">
        </form>
        <div style="text-align:center;padding:5px">
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:107px;height:30px;">提交</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:107px;height:30px;">清除</a>
        </div>
    </div>
</div>
</div>
</body>
<script>
    var optionsNum=0;
    $("#add").click(function() {
        if (optionsNum<4) {
            optionsNum=optionsNum+1;
            var tbody = "<input type='file' name='files'><br>"
            //<td data-id='couplingIndex'>关联标签</td><td data-id='ci'><input class='easyui-textbox' type='text' name='couplingIndex' data-options='required:true'></td>
            //<td data-id='score'>分数</td><td data-id='sc'><input class='easyui-textbox' type='text' name='score' data-options='required:true'></td>
            $("#ff1").append(tbody);
        }
    })

    function submitForm() {
        $('#ff').form('submit', {
            url : 'rest/page/activityM/add',
            onSubmit: function () {
                return $(this).form('enableValidation').form('validate');
            },
            success : function(data){
                var obj = JSON.parse(data)
                if(obj.code == 200){
                    $.messager.show({title:'操作提示',msg:obj.message,showType:'show',style: {
                        top:($(window).height()-200) * 0.5,
                        left:($(window).width() -250) * 0.5
                    }});
                }else{
                    $.messager.show({title:'操作提示',msg:obj.message,showType:'show',style: {
                        top:($(window).height()-200) * 0.5,
                        left:($(window).width() -250) * 0.5
                    }});
                }
                $('#ff').form('clear');
            }
        });
    }
    function clearForm() {
        $('#ff').form('clear');
    }

</script>
</html>